<!-- 证型搜索器 -->
<template>
  <el-autocomplete
    v-model="currentID"
    :fetch-suggestions="querySearchAsync"
    :trigger-on-focus="false"
    placeholder="请输入证型名称 / 证型首字母搜索"
    @select="handleChange"
    style="width: 50%;"
  >
    <template slot-scope="{ item }">
      <div>({{ item.id }}) {{ item.name }}</div>
    </template>
  </el-autocomplete>
</template>

<script>
import { getTCMList } from "@/api/saas/tcm.js";

export default {
  data() {
    return {
      currentID: null,
      getParams: {
        pageNum: 1,
        pageSize: 10,
        keyword: undefined,
      }
    };
  },
  methods: {
    async querySearchAsync(queryString, cb) {
      this.getParams.keyword = queryString;
      const { rows } = await getTCMList(this.getParams);
      cb(rows);
    },
    handleChange(e) {
      this.$emit("change", e);
    },
  },
};
</script>

<style lang="scss" scoped></style>
